<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<base href="#(basePath)"/>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="renderer" content="webkit">
<meta name="force-rendering" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link charset="utf-8" rel="stylesheet" type="text/css" href="/static/ali/ali.css" />
<link charset="utf-8" rel="stylesheet" type="text/css" href="/static/ali/single.css" />
<title>友利钱包账户中心</title>
</head>
<body>
	<header>
		<div class="header-wrapper">
			<div class="welcome">
				<a>商家:#(order.accountName)</a>
			</div>
			<div class="accounts">
				<a>付款方:#(order.merchName)</a>
			</div>
		</div>
	</header>
	<nav>
		<div class="nav-wrapper">
			<div class="logo indexLogo">
				<img src="/static/logo.png" alt="有利钱包 / 商家中心">
			</div>
			<ul class="common-nav-items">
				<li class="common-nav-item active">
					<a><span>友利钱包</span>收银台</a>
				</li>
			</ul>
			<a href="javascript:;" class="nav-qr-code-wrap">
				<span class="nav-qr-code-toggle">手机访问<span class="spIconfont"></span></span>
				<div class="nav-qr-code-layer">
					<img src="" class="nav-qr-code-image">
					<div class="nav-qr-code-desc">
						<div style="line-height: 1.2">用有利钱包扫码关注<br>接收重要信息</div>
					</div>
				</div>
			</a>
		</div>
	</nav>

	<div class="content">
		<div class="content-wrapper">
			<div class="casherdesk">
				<div class="conspicuous">
					<dl class="order-row">
						<dt>收款商家信息</dt>
						<dd>#(order.accountName)</dd>
					</dl>
				</div>
				<dl class="order-row">
					<dt>买家信息</dt>
					<dd>#(order.merchName)<span class="balance">(可用余额：#(buyerBlance)元 )</span></dd>&nbsp;<a href="chargePay">充值</a>
				</dl>
				<dl class="order-row">
					<dt>付款金额</dt>
					<dd><span class="order-money">#(order.amountShow)</span></dd><br>
				</dl>

				<dl class="order-row">
					<dt>大写金额</dt>
					<dd><span class="order-money">#(order.amountInWords)</span></dd>
				</dl>
				<dl class="order-row">
					<dt>商城订单号</dt>
					<dd>#(order.outOrderNo)</dd>
				</dl>
				<dl class="order-row">
					<dt>钱包订单号</dt>
					<dd>#(order.orderNo)</dd>
				</dl>
				<dl class="order-row">
					<dt>备注</dt>
					<dd>#(order.goodsName)</dd>
				</dl>

				#if(payPassword=='null')

					<div class="pay-area">
						<dl class="order-row">
							<input type="hidden" id="userName" name="userName" value="#(buyer.userName)"/>
							<dt>请先设置钱包支付密码：</dt>
							<dd>
								<div><input type="password" id="password1" required="required" name="payPassword1" maxlength="6" minlength="6"/></div>
							</dd>
						</dl>
						<dl class="order-row">
							<dt>请再次确定设置钱包支付密码：</dt>
							<dd>
								<div><input type="password" id="password2" required="required" name="payPassword2" maxlength="6" minlength="6" placeholder="请输入6位数字支付密码"/></div>
							</dd>
						</dl>
						<p>请输入6位数字支付密码</p>
					</div>
					<div class="btn-area">
						<button class="jui-btn jui-btn-blue"  onclick="setPayPassword('#(order.orderNo)')">确认设置</button>
					</div>
				#else
				<div class="dashed-line"></div>
				<form action="" onsubmit="return false" method="post">
					<div class="pay-area">
						<dl class="order-row">
							<input type="hidden" name="orderNo" value="#(order.orderNo)"/>
							<dt>钱包支付密码</dt>
							<dd>
								<div><input id="payPassword" type="password" required="required" name="payPassword" maxlength="6" minlength="6"/>
									<a href="/customer/home/paypswd/reset">忘记密码？</a></div>
							</dd>
						</dl>
						<p>请输入6位数字支付密码</p>
					</div>
					<div class="btn-area">
						<button class="jui-btn jui-btn-blue" lay-submit lay-filter="submitReview" >确认支付</button>
					</div>
				</form>
				#end
			</div>
		</div>
	</div>

	#include("common/footer.html")

	<script src="/static/layui/layui.js"></script>
	<script type="text/javascript">
        layui.config({
            version: "3.0.0",
            base: '/static/fly/mods/'
        }).extend({
            fly: 'index'
        }).use(['form', 'layer'], function(){
            var $ = layui.$, form = layui.form;

            var orderNo = '#(order.orderNo)';
            form.on("submit(submitReview)", function(data){
                gotopay(orderNo);
            });
            function gotopay(orderNo){
                //alert(orderNo);
                //window.location.href= "customer/casherdesk/payment?orderNo=" + orderNo;
                var payPassword = $("#payPassword").val();
                $.ajax({
                    url:"customer/casherdesk/payment?orderNo=" + orderNo,
                    data: "payPassword=" + payPassword,
                    type: "POST",
                    dataType: 'json',
                    success: function (data) {
                        console.log(JSON.stringify(data));
                        if(data.respCode == "00"){
                            window.location.href = data.url;
                        }else {
                            alert(data.respMsg);
                        }
                    },
                    error:function (data) {
                        alert("error:网络错误,请稍后重试");
                    }
                });
            }

        });


        function setPayPassword(orderNo) {
            var userName = document.getElementById("userName").value;
            var password1 = document.getElementById("password1").value;
            var password2 = document.getElementById("password2").value;
            alert(userName + "," + password1 + "," + password2);

            if(password1.length!=6 || password2.length!=6){
                alert("密码长度错误!长度必须6位");
                return;
            }

            if(password1!=password2){
                alert("两次密码不一致!");
                return;
            }

            window.location.href="/customer/casherdesk/setPayPassword?userName=" + userName +
                "&payPassword1=" +password1 + "&&payPassword2=" +password2 + "&orderNo=" +orderNo;


        }
	</script>

</body>
</html>
